<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="../lib/jquery/jquery-1.11.1.js" ></script>
		<script type="text/javascript">
			function selAll(){
				$('.hby').prop('checked',true);
			}
			function selNotAll(){
				$('.hby').prop('checked',false);
			}
			function selFan(){
				for (var i =0; i < $('.hby').length; i++) {
					var flag = $('.hby:eq('+i+')').prop('checked');
					console.log(flag);
					$('.hby:eq('+i+')').prop('checked',!flag);
				}
			}
		</script>
	</head>
	<body>
		<h1>全选、全不选、反选操作</h1>
        爱好：
        <input type="checkbox" checked="true" class="hby" name="hobby" value="1" />篮球&nbsp;
        <input type="checkbox" class="hby" name="hobby" value="2" />足球&nbsp;
        <input type="checkbox" class="hby" name="hobby" value="3" />排球&nbsp;
        <input type="checkbox" class="hby" name="hobby" value="4" />乒乓球&nbsp;
        
        <br /><br />
        <input type="button" value="全选" onclick="selAll()" />
        <input type="button" value="全不选" onclick="selNotAll()" />
        <input type="button" value="反选" onclick="selFan()" />
	</body>
</html>
